#include <iostream>

using namespace std;

const int totalCoins = 12;

void concatenate(char *real, char *subReal)
{
	int i = 0, j = 0;
	int len = strlen(real);
	while (subReal[i] != 0) {
		bool isContain = false;
		j = 0;
		while (j < len) {
			if (subReal[i] == real[j]) {
				isContain = true;
				break;
			}
			++j;
		}
		if (!isContain) {
			real[strlen(real)] = subReal[i];
		}
		++i;
	}
}

void concatenate(char *real, char *left1, char *left2)
{
	int i = 0, j = 0;
	char temp[totalCoins + 1];
	memset(temp, 0, totalCoins + 1);

	int k = 0;
	for (i = 0; i < (int)strlen(left1); i++) {
		bool isEqual = false;
		for (j = 0; j < (int)strlen(left2); j++) {
			if (left1[i] == left2[j]) {
				isEqual = true;
				break;
			}
		}
		if (!isEqual) 
			temp[k++] = left1[i];
	}

	for (i = 0; i < (int)strlen(left2); i++) {
		bool isEqual = false;
		for (j = 0; j < (int)strlen(left1); j++) {
			if (left2[i] == left1[j]) {
				isEqual = true;
				break;
			}
		}
		if (!isEqual) 
			temp[k++] = left2[i];
	}

	concatenate(real, temp);	
}

int find(char *real, char *left)
{
	int i = 0, j = 0;
	for (i = 0; i < (int)strlen(left); i++) {
		bool isEqual = false;
		for (j = 0; j < (int)strlen(real); j++) {
			if (real[j] == left[i]) {
				isEqual = true;
				break;
			}
		}
		if (!isEqual)
			return i;
	}

	return -1;
}

int main(int argc, char* argv[])
{
	int caseNum;
	cin>>caseNum;
	const char *up = "up";
	const char *down = "down";
	const char *even = "even";

	
	const int weighings = 3;
	char real[totalCoins + 1];
	char counterfeitAlternative[totalCoins + 1];
	char left[weighings][totalCoins / 2 + 1];
	char right[weighings][totalCoins / 2 + 1];
	int result[weighings];
	char balance[5];
	while (caseNum > 0)
	{
		int group = 0;
		for (; group < weighings; group++) {
			memset(left[group], 0, totalCoins / 2 + 1);
			memset(right[group], 0, totalCoins / 2 + 1);
			cin>>left[group]>>right[group]>>balance;
			int re = strcmp(balance, even);
			result[group] = re;
		}
		
		memset(real, 0, totalCoins + 1);
		for (int i = 0; i < group; i++) {
			if (result[i] == 0) {
				concatenate(real, left[i]);
				concatenate(real, right[i]);
			}
		}

		for (int i = 0; i < group - 1; i++) {
			if (result[i] != 0) {
				for (int j = i + 1; j < group; j++) {
					if (result[j] != 0) {
						if (result[i] > 0 && result[j] > 0) {
							concatenate(real, left[i], left[j]);
							concatenate(real, right[i], right[i]);
						} else if (result[i] > 0) {
							concatenate(real, left[i], right[j]);
							concatenate(real, left[j], right[i]);
						} else if (result[j] > 0) {
							concatenate(real, left[i], right[j]);
							concatenate(real, left[j], right[i]);
						} else {
							concatenate(real, left[i], left[j]);
							concatenate(real, right[i], right[i]);
						}
					}
				}
			}
		}

		// 
		for (int i = 0; i < group; i++) 
		{
			if (result[i] != 0) {
				int idx = find(real, left[i]);
				if (idx == -1) {
					idx = find(real, right[i]);
					if (result[i] > 0)
						cout<<right[i][idx]<<" is the counterfeit coin and it is light."<<endl; 
					else
						cout<<right[i][idx]<<" is the counterfeit coin and it is heavy."<<endl;
				} else {
					if (result[i] > 0)
						cout<<left[i][idx]<<" is the counterfeit coin and it is heavy."<<endl; 
					else
						cout<<left[i][idx]<<" is the counterfeit coin and it is light."<<endl;
				}
				

				break;
			}
		}


		--caseNum;
	}
	return 0;

}